﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Statistic
{
    public class Parser
    {
        public static string HtmlToXmlString(string value)
        {
            string newString = "";
            string[] stringTable = value.Split('▒');
            var stringParts = from s in stringTable
                    select s;

            int coco=0;
            newString = "<Advertisements>";
            int end = stringParts.Count() / 2;
            for (int i = 0; i < end; i++)
            {
                newString += "<Advertisement id =" + "\"" + i + "\"" + ">";
                newString += "<AdvertisementLink>"+ stringTable[0 + coco] + "</AdvertisementLink>";
                newString += "<Date>" + stringTable[1 + coco] + "</Date>";
                newString += "</Advertisement>";
                coco += 2;          
            }
            newString += "</Advertisements>";
            string newnewstring = newString.Replace("&", "");
            return newnewstring;
        }
    }
}
